//
//  HomeOwnViewModel.swift
//  imprint
//
//  Created by 小柠檬🍋 on 2025/2/3.
//

import Foundation
class StatisticsTagListViewModel : BaseViewModel {
    @Published var items = [DiaryBean]()
    @Published var status = ""

    func getData(_ isRefresh: Bool = false, bean: TagBean) {
        requestList(isRefresh: isRefresh) {
            showLog("tagId:\(String(describing: bean.objectId))")
            let list = try await BackupsManager.shared.getDelegateDiary()?.queryTag(
                userId: userManager.getUserId(),
                tagId: bean.objectId,
                pageNo: self.pageNo,
                pageSize: self.pageSize
            ) ?? []
            try check(!isRefresh || !list.isEmpty, "暂无数据")
            return list
        } suc: { diarys in
            self.status = ""
            self.items.append(contentsOf: diarys)
        } fail: {
            self.status = $0.message
        }
    }
}
